package com.darren.archive.dao.impl;

import com.darren.archive.dao.SysUserDao;
import com.darren.archive.entity.SysUser;
import com.darren.framework.dao.impl.GenericDaoImpl;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;


@Repository
public class SysUserDaoImpl extends GenericDaoImpl<SysUser, Long> implements SysUserDao {

	@Override
	public SysUser findByUserAccountOrMobile(String queryString) {
		Session session  = sessionFactory.getCurrentSession();
		Query<SysUser> query = (Query<SysUser>) session.createQuery(" from SysUser where userAccount = :userAccount or mobile = :mobile ",SysUser.class);
		query.setParameter("userAccount", queryString);
		query.setParameter("mobile", queryString);
		return query.uniqueResult();
	}
}